#pragma once
#include "../../common/include/obj.h"
#include "bc_kernel_i.h"
#include <string.h>

class C_ECB_MODE : public CVirtualDestruct
{ // C_ECB_MODE是所有模式的基类
public:
    virtual int GetIV(BYTE *data, int *piLen = nullptr)
    {
        if(piLen) *piLen = 0;
        return 1;
    };

    virtual int SetIV(BYTE *data, int iLen) { return 1; };

    virtual int IVlen(){ return 0; };

    virtual int Encrypt(BYTE *pIn, int iLenIn, BYTE *pOut, int *piLenOut, IBlockCipherKernel *pobjKer);
    virtual int Decrypt(BYTE *pIn, int iLenIn, BYTE *pOut, int *piLenOut, IBlockCipherKernel *pobjKer);
};

class C_IV16_MODE : public C_ECB_MODE
{ // 使用16字节IV的基类
public:
    C_IV16_MODE() { bzero(m_bfIV, 16); };

    virtual int GetIV(BYTE *data, int *piLen = nullptr);
    virtual int SetIV(BYTE *data, int iLen);
    virtual int IVlen(){ return 16; };

protected:
    BYTE m_bfIV[16];
};
